/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import controller.ConverterFacade;
import javax.inject.Named;
import javax.enterprise.context.SessionScoped;
import java.io.Serializable;
import javax.ejb.EJB;

/**
 *
 * @author Guillaume
 */
@Named(value = "converterManager")
@SessionScoped
public class ConverterManager implements Serializable {

    private Float fromAmount;
    private Float toAmount;
    private String fromCurrency;
    private String toCurrency;
    @EJB
    ConverterFacade converterFacade;

    /** Creates a new instance of ConverterManager */
    public ConverterManager() {
    }

    public void convert() {
        converterFacade.convert(fromAmount, fromCurrency, toCurrency);
        this.toAmount = converterFacade.convertedAmount();
    }

    public void setFromAmount(Float amount) {
        this.fromAmount = amount;
    }

    public Float getFromAmount() {
        return this.fromAmount;
    }

    public void setToAmount(Float amount) {
        this.toAmount = amount;
    }

    public Float getToAmount() {
        return this.toAmount;
    }
    
    public void setFromCurrency(String currency){
        this.fromCurrency = currency;
    }
    
    public void setToCurrency(String currency){
        this.toCurrency = currency;
    }
}
